package com.itheima.a01;

import org.springframework.context.event.EventListener;
import org.springframework.core.MethodIntrospector;
import org.springframework.core.annotation.AnnotatedElementUtils;

import java.lang.reflect.Method;
import java.util.Map;

public class MethodIntrospectorDemoOne {
    public static void main(String[] args) {

        Class targetType = Component2.class;

        Map<Method, EventListener> annotatedMethods = null;
        try {
            annotatedMethods = MethodIntrospector.selectMethods(targetType,
                    (MethodIntrospector.MetadataLookup<EventListener>) method ->
                            AnnotatedElementUtils.findMergedAnnotation(method, EventListener.class));
            System.out.println(annotatedMethods);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
